/*
 * @Author: xiaosihan 
 * @Date: 2023-08-21 22:46:28 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2023-09-06 17:49:42
 */

import designDataHistory from "@/editorComponent/designDataHistory";
import { Tooltip } from "antd";
import clsx from "clsx";
import { autorun } from "mobx";
import { useEffect, useRef, useState } from "react";
import redoSVG from "./redo.svg?raw";
import styles from "./toolRedo.module.less";

interface Iprops {
}


// 前进
export default function ToolRedo() {

    const dom = useRef<HTMLDivElement | null>(null);
    const [data, setData] = useState({});
    const [disable, setDisable] = useState(true);
    const [redoNum, setRedoNum] = useState(0);

    useEffect(() => {

    }, []);

    useEffect(() => autorun(() => {
        const { redoNum } = designDataHistory.store;
        setRedoNum(redoNum);
    }), []);

    return (
        <Tooltip
            title="重做(ctrl+y)"
            placement="bottom"
            mouseLeaveDelay={0}
            mouseEnterDelay={0.5}
        >
            <span
                className={clsx(styles.toolRedo, (redoNum === 0) && styles.disable)}
                dangerouslySetInnerHTML={{ __html: redoSVG }}
                onClick={(e) => {
                    designDataHistory.redo();
                }}
                onMouseUp={e => {
                    e.stopPropagation();
                    e.preventDefault();
                }}
            >
            </span>
            {/* {redoNum} */}
        </Tooltip>
    );

}